package Default;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

import world.Target;
import world.World;

public class WorldPanel  extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 7403401623778343177L;
	World world;
	int nodeSize;
	public WorldPanel(World _world)
	{
		world=_world;
		nodeSize=Variables.gridZoom/2;
		//setBounds(0, 0, 400, 120);
		setPreferredSize(new Dimension(Variables.gridSizeX*nodeSize+nodeSize,Variables.gridSizeY*nodeSize+nodeSize));
		
	}
	public void paint(Graphics g)
	{
		int i=0;
		Target target;
		//System.out.println("paint: "+world.targets.size());
		for(i=0;i<world.targets.size();i++)
		{
			
			target=world.targets.get(i);
			g.setColor(Color.magenta);
			g.drawLine((target.start.x)*nodeSize, (target.start.y)*nodeSize, (target.end.x+1)*nodeSize, (target.end.y+1)*nodeSize);
			g.setColor(Color.black);
			g.fillOval((target.location.x+1)*nodeSize-2, (target.location.y+1)*nodeSize-2, 4, 4);
		}
		
		
		g.setColor(Color.GRAY);
		g.drawRect(Variables.sense_radius*nodeSize,Variables.sense_radius*nodeSize , Variables.x*nodeSize, Variables.y*nodeSize);
		
	}
}
